//路由守卫
import { TokenService } from "@/package/auth/token/token.service";
import { ITokenService } from "@/package/auth/token/interface";
import { AUTH_DEFAULT_CONFIG } from "../auth/auth.config";
import { ITokenModel } from "@/package/auth/token/interface";

const ACLGuard = function (to: any): boolean {
    return true
}

const SimpleGuard = function (to: any): boolean {
    let tokenSrv: ITokenService = new TokenService();
    let token = tokenSrv.get()?.token
    const bool = token != null && typeof token === 'string' && token.length > 0;
    let nowDate = new Date().getTime()
    let item = tokenSrv.get() as ITokenModel;
    if (!bool) {
        //跳转至登录页
        location.href = AUTH_DEFAULT_CONFIG.login_url as string
        tokenSrv.clear()
    }
    return bool
}


export { ACLGuard, SimpleGuard }






